package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.GetPartnerByDeptReqDto;
import com.yixun.qfbao.apidto.GetPartnerByDeptResDto;
import com.yixun.qfbao.apidto.GetUserByIdReqDto;
import com.yixun.qfbao.apidto.GetUserByIdResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetPartnerByDeptReqVo;
import com.yixun.qfbao.vo.GetUserByIdReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/11/25
 * @Author sangtao
 * @Computer Administrator
 */
@Service("getUserByIdHander")
public class GetUserByIdHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetUserByIdHander.class);
    @Autowired
    PersonnelService personnelService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetUserByIdReqVo req = (GetUserByIdReqVo)reqDto;
        GetUserByIdReqDto getUserByIdReqDto = req.getParams();
        BaseResponseDTO<GetUserByIdResDto> res = new BaseResponseDTO<GetUserByIdResDto>();
        GetUserByIdResDto resDto = new GetUserByIdResDto();
        try{
            resDto = personnelService.getUserById(getUserByIdReqDto);
        } catch (Exception e) {
            logger.error("GetUserByIdHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("实时获取用户信息失败");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
